<?php
echo form_open("/lihat_nilai/cari/", array("name"=>"form_nilai_mahasiswa","id"=>"form_nilai_mahasiswa"));
$tahun_ajaran	= set_value("nama_kelas");
$semester		= set_value("semester");
$kelas			= set_value("kelas");
$jurusan		= set_value("jurusan");
$program		= set_value("program");
?>
<h4>Form Nilai Mahasiswa PENS-ITS (RAPAT)</h4>
<hr>
<div class="row">
<p class="span3">
	<label>Tahun</label>
	<select name="tahun" id="tahun">
		<option value="">-- Pilih Tahun Ajaran--</option>
		<?php
		foreach($qt_ajaran as $row){
		?>
		<option value="<?php echo $row["ID_TAHUN_AJARAN"]; ?>" <?php echo ($tahun_ajaran == $row["ID_TAHUN_AJARAN"]) ? ("selected") : (""); ?>><?php echo $row["TAHUN_AJARAN"]; ?></option>
		<?php
		}
		?>
	</select>
	<?php echo form_error("tahun"); ?>
</p>
<p class="span3">
	<label>Semester</label>
	<select name="semester" id="semester">
		<option value="">-- Pilih Semester --</option>
		<option value="1" <?php echo ($semester == 1) ? ("selected") : (""); ?>>Ganjil</option>
		<option value="2" <?php echo ($semester == 2) ? ("selected") : (""); ?>>Genap</option>
	</select>
	<?php echo form_error("semester"); ?>
</p>
<p class="span3">
	<label>Nama Jurusan</label>
	<select name="jurusan" id="jurusan">
		<option value="">-- Pilih Nama Jurusan --</option>
		<?php
		foreach($qjurusan as $row){
		?>
		<option value="<?php echo $row["ID_JURUSAN"]; ?>" <?php echo ($jurusan == $row["ID_JURUSAN"]) ? ("selected") : (""); ?>><?php echo $row["NAMA_JURUSAN"]; ?></option>
		<?php
		}
		?>
	</select>
	<?php echo form_error("jurusan"); ?>
</p>
<p class="span3">
	<label>Program Pendidikan</label>
	<select name="program" id="program">
		<option value="">-- Pilih Nama Program Pendidikan --</option>
		<?php
		foreach($qprogram as $row){
		?>
		<option value="<?php echo $row["ID_PROGRAM"]; ?>" <?php echo ($program == $row["ID_PROGRAM"]) ? ("selected") : (""); ?>><?php echo $row["NAMA_PROGRAM"]; ?></option>
		<?php
		}
		?>
	</select>
	<?php echo form_error("program"); ?>
</p>
<p class="span3">
	<label>Nama Kelas</label>
	<select name="kelas" id="kelas" disabled>
		<option value="">-- Pilih Nama Kelas --</option>
		<?php
		foreach($qkelas as $row){
		?>
		<option value="<?php echo $row["ID_KELAS"]; ?>" <?php echo ($kelas == $row["ID_KELAS"]) ? ("selected") : (""); ?>><?php echo $row["NAMA_KELAS"]; ?></option>
		<?php
		}
		?>
	</select>
	<?php echo form_error("kelas"); ?>
</p>
<p class="span3">
	<label>&nbsp;</label>
	<button type="button" class="btn btn-primary" id="submit"><span class="icon-search icon-white"></span> Cari</button>
	<button type="reset" class="btn btn-primary"><span class="icon-remove icon-white"></span> Reset</button>
</p>
<?php echo form_close(); ?>
<script language="javascript">
	$("#submit").click(function() {
		$.ajax({
			   type: "POST",
			   url:'<?php echo site_url("lihat_nilai/cari/"); ?>',
			   data:$("#form_nilai_mahasiswa").serialize(),
			   success: function(data)
			   {
					// alert(data);
					$("#grid-nilai").html(data);
			   }
			 });

		return false;
	});
	$("#jurusan").change(function(){
		var jurusan = {jurusan:$("#jurusan").val()};
		$.ajax({
			type: "POST",
			url : "<?php echo site_url('/lihat_nilai/select_kelas')?>",
			data: jurusan,
			success: function(msg){
				if(msg == ""){
					$("#kelas").prop('disabled', true);
				} else {
					$("#kelas").prop('disabled', false);
				}
				$("#kelas").html("<option value=\"\">-- Pilih Nama Kelas --</option>"+msg);
			}
		});
	});
</script>
<hr class="span12">
<div id="grid-nilai" class="span12">
	<link href="<?php echo base_url();?>assets/css/flexigrid.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/flexigrid.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/fancy_box/source/jquery.fancybox.js?v=2.1.4"></script>
	<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/js/fancy_box/source/jquery.fancybox.css?v=2.1.4" media="screen" />
	<style>
	.hero-unit {
	line-height:16px;
	}
	select,
	input[type="text"]{
	display: inline-block;
	padding: 2px;
	margin-bottom: 0px;
	font-size: 10pt;
	vertical-align: middle;
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;
	border-radius: 4px;
	}
	select{
	height:26px;
	}
	table{
	border-collapse:separate;
	}
	</style>
	<?php
	echo $js_grid;
	echo $added_js;
	?>
	<table id="flex1"></table>
</div>
</div>